package com.cloud.common.user.controller;

import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @author: lwg
 * @createTime: 2019年11月08日 20:25:00
 */
@RestController
public class UserController {
    @GetMapping("{id}")
    public Map<String, Object> getByIdUser(@PathVariable Integer id) {
        Map<String, Object> userMap = new HashMap<>();
        userMap.put("userId", id);
        return userMap;
    }

    @GetMapping("info")
    public Map<String, Object> getUserInfo(@RequestParam("id") Integer id) {
        if (id == 1232) {
            Map<String, Object> userMap = new HashMap<>();
            List<String> roles = new ArrayList<>();
            roles.add("admin");
            Map<String, Object> dataMap = new HashMap<>();
            dataMap.put("code", 20000);
            dataMap.put("id", 123);
            dataMap.put("name", "LWg");
            dataMap.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
            dataMap.put("introduction", "im lwg");
            dataMap.put("roles", roles);
            userMap.put("data", dataMap);
            return userMap;
        } else {
            Map<String, Object> userMap = new HashMap<>();
            List<String> roles = new ArrayList<>();
            roles.add("editor");
            Map<String, Object> dataMap = new HashMap<>();
            dataMap.put("code", 20000);
            dataMap.put("id", 123);
            dataMap.put("name", "LWg");
            dataMap.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
            dataMap.put("introduction", "im lwg");
            dataMap.put("roles", roles);
            userMap.put("data", dataMap);
            return userMap;
        }

    }
}
